<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>点击切换按钮</title>
    <style>
        /* 设置页面背景样式 */
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f0f0f0;
        }

        /* 按钮基础样式 */
        .button {
            width: 150px;
            height: 60px;
            border: none;
            outline: none;
            border-radius: 30px;
            /* 圆角效果 */
            background-color: #f5f5f5;
            /* 初始背景色 */
            color: #333;
            font-size: 18px;
            font-weight: bold;
            cursor: pointer;
            box-shadow: 4px 4px 10px #ccc, -4px -4px 10px #fff;
            /* 3D阴影效果 */
            transition: all 0.3s ease;
            /* 平滑过渡效果 */
        }

        /* 点击后的样式 */
        .button.active {
            background: linear-gradient(to right, #e0f7fa, #b2ebf2, #b3e5fc);
            /* 渐变背景色 */
            box-shadow: inset 4px 4px 10px #ccc, inset -4px -4px 10px #fff;
            /* 内阴影效果 */
            color: #444;
        }
    </style>
</head>

<body>

    <!-- 按钮 -->
    <button class="button" id="toggleButton">Click</button>

    <script>
        // JavaScript 切换按钮状态
        const button = document.getElementById('toggleButton');

        button.addEventListener('click', () => {
            button.classList.toggle('active'); // 切换 active 类
        });
    </script>

</body>

</html>